{extends file="../global.html"}
{block name=body}



 

      
          <div class="content" >
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form xbs" action="" >
                <div class="layui-form-pane" style="text-align: center;">
                  <div class="layui-form-item" style="display: inline-block;">
                    <!-- <label class="layui-form-label xbs768">日期范围</label>
                    <div class="layui-input-inline xbs768">
                      <input class="layui-input" placeholder="开始日" id="LAY_demorange_s">
                    </div>
                    <div class="layui-input-inline xbs768">
                      <input class="layui-input" placeholder="截止日" id="LAY_demorange_e">
                    </div> -->
                    <div class="layui-input-inline">
                      <input type="text" name="store_name"  placeholder="请输入问题" value="" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width:80px">
                        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                    </div>
                  </div>
                </div> 
            </form>
            <xblock><button class="layui-btn" onclick="window.location.href='add'"><i class="layui-icon">&#xe608;</i>添加</button></xblock>
            <table class="layui-table">
                <thead>
                    <tr>
                     <th style="width:5%">
                          ID
                        </th>
                        <th>
                          门店
                        </th>
                        <th>
                         是否显示在详情页
                        </th>
                        <th>
                          操作
                        </th>
                    </tr>
                </thead>
                <tbody>
                {foreach $res as $k=>$v}

                    <tr class="tr_{$v.store_id}">
                        
                        <td class="td"> {$v.store_id}</td>


                        <td class="td" id="problem_name "> {if $v.paths==0}<i class="layui-icon">&#xe624;</i>{$v.store_name}{else}<i class="layui-icon">　　&#xe621; </i>公司:{$v.store_company}<br/>　　　　门店地址:{$v.store_name}<br/>　　　　电话:{$v.store_phone}{/if}</td>
                        
                        <td class="td-status">
                            {if $v.paths!=0}
                            <input type="hidden" class="state_{$v.store_id}" name="store_state" value="{$v.store_state}">
                            <span class="layui-btn  {if $v.store_state==0} layui-btn-normal {else} layui-btn-danger {/if} layui-btn-mini state-{$v.store_id}" onclick="state({$v.store_id})">{if $v.store_state==0}显示{else}隐藏{/if}</span>
                            {/if}
                        </td>
                        
                        <td class="td-status">
                                 {if $v.paths==1}
                             <!--  <a title="编辑"                                
                            class="ml-5 update"　href="{url('/run/store/edit/id/'|cat:$v.store_id)}" style="text-decoration:none">
                                <i class="layui-icon">&#xe642;</i>
                              </a> -->
                                <a title="编辑" href="{url('/run/store/edit/id/'|cat:$v.store_id)}"  
                                          style="text-decoration:none">
                               
                                    <i class="layui-icon">&#xe642;</i>
                                </a>
                              <a title="删除" href="javascript:del({$v.store_id})"  
                                          style="text-decoration:none">
                               
                                    <i class="layui-icon">&#xe640;</i>
                                </a>
                                {/if}
                        
                        </td>
                    </tr>
                   {/foreach}
                </tbody>

            </table>
            <!-- 右侧内容框架，更改从这里结束 -->
             
          </div>
          <script type="text/javascript">
            function del(store_id){

              $.ajax({
                type:'post',
                data:{ store_id:store_id},
                url:"{url('run/store/ajaxDel')}",
                success:function(msg){
                    if(msg == true){
                      alert('删除成功');
                      $('.tr_'+store_id).remove();
                    }

                }
             })
            }
             

            function state(store_id){
                // alert(store_id);
                var tex = $('.state-'+store_id).text();
                // console.log($('state-'+store_id));
                // alert(tex);return;
                var store_state = $('.state_'+store_id).val();
                $.ajax({
                  type:'post',
                  data:{ store_id:store_id,store_state:store_state},
                  url:"{url('run/store/ajaxState')}",
                   success:function(msg){
                    // alert(msg);
                    if(msg == true){
                      if(tex == '隐藏'){
                          $('.state-'+store_id).text('显示').removeClass('layui-btn-danger').addClass('layui-btn-normal');
                                      $('.state_'+store_id).val('0')  
                      }else{
                         $('.state-'+store_id).text('隐藏').removeClass('layui-btn-normal').addClass('layui-btn-danger');
                                      $('.state_'+store_id).val('1')  
                      }
                    }

                }
                }) 

            }
         
 
   

          </script>
        
{/block}
